import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.Jedis;
import ssm_zxw.mapper.RoleMapper;
import ssm_zxw.pojo.Role;
import ssm_zxw.redis.jedisUtils;

import java.util.List;

public class test {

    @Autowired
    private static RoleMapper roleMapper;
    public static void main(String[] args) {
        Jedis jedis = jedisUtils.getJedis();
        String role = jedis.get("role");
        ObjectMapper mapper = new ObjectMapper();
        if (role == null  || role.length() == 0) {
            List list = roleMapper.findALl();
            try {
                role = mapper.writeValueAsString(list);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
            jedis.set("role", role);
            jedis.close();
        }
        List<Role> list = JSONObject.parseArray(role,Role.class);
        System.out.println(list);

    }
}
